package so.go4.controller;

import com.alibaba.fastjson.JSON;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import so.go4.model.User;
import so.go4.service.IUserService;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by SQB on 2015/4/22.
 */
@Controller
@RequestMapping("/vo")
public class UserController {
    private static Logger logger = Logger.getLogger(UserController.class);
    @Autowired
    IUserService userService;

/*    @RequestMapping("/testvo")
    public ModelAndView listall(HttpServletRequest request,HttpServletResponse response){
//        this.userService.getUserById(1);
        String tea = request.getParameter("teacher");
        System.out.println(tea + "teacher123!!!!");
        ModelAndView mav=new ModelAndView("list");
        logger.info("hahaha1a2222");
        return mav.addObject("user","useruser");
    }*/
     @RequestMapping("/list")
    public ModelAndView listall(HttpServletRequest request,HttpServletResponse response){
        User user = userService.getUserById(1);
        // System.out.println(user.getUserName());
        // logger.info("值："+user.getUserName());
        ModelAndView mav=new ModelAndView("list");
        logger.info(JSON.toJSONString(user));
        return mav.addObject("user",user);
    }
}

